@extends('frontend/layouts/default')

@section('content')

<h1>All Car Maker</h1>
<div class="container">
@if ($carMakers->count())
    <div id="tree-domains-view" style="position:relative;"></div>
@else
    There are no car makers
@endif
</div>
<p>{{ link_to_route('car_balance.carmaker.create', 'Add new Car Maker', null, array('class' => 'btn btn-info')) }}</p>
@stop

@section('pagestyles')
    <link rel="stylesheet" href="{{ asset('assets/tree/backbone-treeview.css') }}" />
@stop

@section('pagescripts')

<script type="text/template" id = "tree-domains-template">
<span class="node-collapse"> 
    <span class="node-label"><%- name %></span>
    <span class="node-data">
        id:<%- id %> parent:<%- node_parent %> left:<%- node_left %> right:<%- node_right %> depth:<%- node_depth %>
    </span>
    <span class="node-action pull-right">
        <a class="btn btn-mini btn-info" href="{{URL::current()}}/<%- id %>/edit">Edit</a>
        <a class="btn btn-mini btn-primary" href="{{URL::current()}}/<%- id %>">Show</a>
        <a class="btn btn-mini btn-primary" href="{{URL::current()}}/<%- id %>/up" >Up</a>
        <a class="btn btn-mini btn-primary" href="{{URL::current()}}/<%- id %>/down" >Down</a>
        <a class="btn btn-mini btn-danger" href="{{URL::current()}}/<%- id %>/destroy" data-method="DELETE">Delete</a>
    </span>
</span>
</script>

<script src="{{ asset('assets/tree/backbone-treeview.js') }}"></script>
<script src="{{ asset('assets/bq/linksubmit.js') }}"></script>

<script type="text/javascript">
(function(){
var treeDomainCollection = new Backbone.TreeNodeCollection( {{$jsonCarMaker}} );
var treeDomainCollectionView = new Backbone.TreeNodeCollectionView({
    collection: treeDomainCollection,
    nodetemplate: '#tree-domains-template',
    nodeid : null});
$('#tree-domains-view').html(treeDomainCollectionView.render().el);
})();
</script>

@stop
